package com.xiashitech.agent.instrumentation.base.inst;

import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;

/**
 * 插桩基类，封装advice名称获取等操作
 * @author zhaoyk
 */
abstract public class CommonInstrumentation implements TypeInstrumentation {

    private String adviceName(String advice) {
        return getClass().getName() + '$' + advice;
    }

    protected void transformMethod(ElementMatcher<? super MethodDescription> method, String advice, TypeTransformer transformer) {
        transformer.applyAdviceToMethod(method, adviceName(advice));
    }

}
